﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;

namespace GoodroommateComputingPlatform.Models.Goodroommate
{
    public class GoodroomDbContext : DbContext
    {
        public GoodroomDbContext(DbContextOptions<GoodroomDbContext> options)
            : base(options)
        { }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity<User>(entity =>
            {
                entity.HasKey(e => e.ID);
            });
            modelBuilder.Entity<UserDetail>(entity =>
            {
                entity.HasKey(e => e.DetailID);
            });
            modelBuilder.Entity<UserInfo>(entity =>
            {
                entity.HasKey(e => e.InfoID);
            });
            modelBuilder.Entity<KeyData>(entity =>
            {
                entity.HasKey(e => e.Key);
            });
            modelBuilder.Entity<UserInfoGrouped>(entity =>
            {
                entity.HasKey(e => e.UserID);
            });
            modelBuilder.Entity<University>(entity =>
            {
                entity.HasKey(e => e.ID);
            });
            modelBuilder.Entity<DomitoryPreference>(entity=>
            {
                entity.HasKey(e=>e.UserID);
            });
            modelBuilder.Entity<TempGroupData>(entity=>
            {
                entity.HasKey(e=>e.ID);
            });
        }

        public virtual DbSet<User> users { get; set; }
        public virtual DbSet<UserDetail> userdetails { get; set; }
        public virtual DbSet<UserInfo> userinfo { get; set; }
        public virtual DbSet<KeyData> keydata { get; set; }
        public virtual DbSet<UserInfoGrouped> userinfo_grouped { get; set; }
        public virtual DbSet<University> universities { get; set; }
        public virtual DbSet<DomitoryPreference> domitorypreference{get;set;}
        public virtual DbSet<TempGroupData> temp{get;set;}

    }
}
